<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
    function regist() {
        console.log('regist()')
        $.ajax({
            url: '/user/regist',
            type: 'post',
            dataType: 'text',
            data: {"username": $('#username').val(), "password": $('#password').val()},
            success: function (d) {
                if (d) {
                    window.location.href = 'login.html';
                } else {
                    window.location.href = 'regist.html';
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.status); // 200
                alert(textStatus); // parsererror
                alert(errorThrown); // SyntaxError: Unexpected end of input
            }
        })
    }
</script>
<body>
<div>
    <!--用户名:<input name="username" id="username"  type="text"/><br>-->
    <!--密码:<input name="password" id="password"  type="password"> <br>-->
    <!--<input type="button" οnclick="regist()" value="注册">-->

    <form action="/user/regist" method="post">
        用户名:<input name="username" type="text"/><br>
        密码:<input name="password" type="password"> <br>
        <input type="submit" value="注册">
    </form>

</div>
</body>
</html>